﻿using System.Collections.Generic;
using AutoMapper;

namespace OrderMicroService.Infrastructure.Repository.Converter
{
    public class DoConverter
    {
        protected readonly Mapper mapper;

        public DoConverter(Mapper mapper)
        {
            this.mapper = mapper;
        }

        public TDo ToDO<TEntity, TDo>(TEntity source)
        {
            return mapper.Map<TEntity, TDo>(source);
        }

        public IEnumerable<TDo> ToDOs<TEntity, TDo>(IEnumerable<TEntity> source)
        {
            return mapper.Map<IEnumerable<TEntity>, IEnumerable<TDo>>(source);
        }

        public TEntity ToEntity<TDo, TEntity>(TDo source)
        {
            return mapper.Map<TDo, TEntity>(source);
        }

        public IEnumerable<TEntity> ToEntitys<TDo, TEntity>(IEnumerable<TDo> source)
        {
            return mapper.Map<IEnumerable<TDo>, IEnumerable<TEntity>>(source);
        }
    }
}